#pragma once
#include"(new)RBTree.h"
using namespace std;

namespace linhui
{
	template<class Key, class Val>
	class myMap
	{
	public:
		struct KeyOfVal
		{
			Key operator()(const pair<Key, Val>& item)
			{
				return item.first;
			}
		};
		using iterator = typename BRTree<Key, pair<Key, Val>, KeyOfVal>::iterator;
		using cosnt_iterator = typename BRTree<Key, pair<Key, Val>, KeyOfVal>::const_iterator;
		pair<iterator,bool> Insert(const pair<Key, Val>& input)
		{
			return _self.Insert(input);
		}
		iterator begin()
		{
			return _self.begin();
		}
		iterator end()
		{
			return _self.end();
		}
		Val& operator[](Key key)
		{
			pair<iterator, bool> ret = _self.Insert({key,Val()});
			return ret.first->second;
		}
	private:
		BRTree<Key, pair<Key, Val>, KeyOfVal> _self;
	};

}